package com.qf.common;

import com.qf.aop.annocation.FormToken;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultEntity<T> {

    private static final String SUCCESS = "success";
    private static final String ERROR = "error";

    private String status; // 响应的状态

    private String msg; // 响应的信息

    private T data; // 响应的数据

    // 请求成功
    public static <T> ResultEntity<T> success() {
        return new ResultEntity<T>(SUCCESS, null, null);
    }

    public static <T> ResultEntity<T> success(T data) {
        return new ResultEntity<T>(SUCCESS, null, data);
    }

    public static <T> ResultEntity<T> error(String msg) {
        return new ResultEntity<T>(ERROR, msg, null);
    }

    public static <T> ResultEntity<T> error(String msg, T data) {
        return new ResultEntity<T>(ERROR, msg, data);
    }

    public static <T> ResultEntity<T> write(Object falg) {
        if (falg instanceof Boolean) {
            if ((Boolean) falg) {
                return success();
            } else {
                return error(null);
            }
        } else if (falg instanceof Integer) {
        }
        return error(null);
    }


}
